package com.fengxing.ams.web.task;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.fengxing.ams.pub.manager.intf.IConfigManager;
import com.fengxing.ams.web.common.IContextManager;
import com.fengxing.ams.web.facade.mouble.company.ICompanyImportDAO;
import com.fengxing.ams.web.facade.mouble.user.IUserDAO;

@Component
public class IdsSyncerTask {

	private static final Log logger = LogFactory.getLog(IdsSyncerTask.class);
	@Autowired
	IContextManager contextManager;
	@Autowired
	IConfigManager configManager;
	@Autowired
	IUserDAO userDAO;
	@Autowired
	ICompanyImportDAO companyImportDAO;
	
	public void syncAction() {
		long lastTime = System.currentTimeMillis();
		logger.info("syncAction start:" + lastTime);
		//查询所有的学号和enterprise id
		List<String> studentIds = this.userDAO.findAllStudentId();
		List<String> ids = this.companyImportDAO.findAllIds();
		studentIds.addAll(ids);
		this.configManager.syncIds(studentIds);
		logger.info("syncAction end:" + (System.currentTimeMillis() - lastTime));
	}
	
}